class Mypromise{
    constructor(fn){
        this._topics= [];
        var r=this._resolve.bind(this)
        fn(r);
    }
    then(callback){
        this._topics.push(callback);
        return this;
    }
    _resolve(val){
        this._topics.forEach(callback=>{
            callback(val);
        })
    }
}

function readFile(a){
    return new Mypromise(resolve=>{
        setTimeout(()=>{
            console.log(a);
            resolve(a);
        },500)
    })
}

readFile('a')
    .then(()=>{
        console.log('b')
    })
    .then(()=>{
        console.log('c')
    });